﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ZHDJ.WebPage;
using ZHDJ.Data.Models.Org;
using ZHDJ.WebPage.Master;
using ZHDJ.Data.BLL;

namespace ZHDJ.Web.Portal.BranchHome
{
    public partial class BranchInfo : UseMorePageMasterPage
    {
        /// <summary>
        /// BranchID
        /// </summary>
        private string BranchID
        {
            get
            {
                return this.Request["BranchID"] ?? "null";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        public void LoadData()
        {
            var info = PartyOrgBranch.GetBranchBId(BranchID);
            if (info == null || info.Rows.Count<1)
            {
                RedirectTo("default", "~/default.aspx");
            }
            this.litAddress.Text = Convert.ToString(info.Rows[0]["Address"]);
            this.litBranchMark.Text = Convert.ToString(info.Rows[0]["BranchMarkName"]);
            this.litBranchName.Text = Convert.ToString(info.Rows[0]["BranchName"]);
            this.litdBranchType.Text = Convert.ToString(info.Rows[0]["BranchTypeName"]);
            this.litParentName.Text = Convert.ToString(info.Rows[0]["ParentBranchIName"]);

            var dt = PartyScoreHelper.QueryBranchScore(BranchID);
            if (dt.Rows.Count > 0)
            {
                this.litRank.Text = Convert.ToString(dt.Rows[0]["Rank"]);
                this.litScore.Text = Convert.ToString(dt.Rows[0]["Score"]);
            }

            var memberCount = PartyOrgMember.QueryMemberCountByBranchID(BranchID, 0);
            this.litMemberCount.Text = memberCount.ToString();
        }

        /// <summary>
        /// 初始化module  如果通过url传参可不设置
        /// </summary>
        protected override void InitModule()
        {
            Module = "BranchHomeMore";
            Category = "BranchInfo";
        }
        
    }
}